using System.Collections;
using Since.Netcode;
using UnityEngine;

public class Boom : MonoBehaviour
{
	public float time = 0.2f;
	public Vector3 BoomPosition;

	void Start()
	{
		// 计算从当前位置到爆炸点的方向
		Vector3 direction = (transform.position - BoomPosition).normalized;
		// 设置一个固定的爆炸速度大小
		float boomSpeed = 10f;
		var velocity = direction * boomSpeed;
		velocity.z = 0;

		GetComponent<NetcodeTransform>().SetVelocity(velocity);
		StartCoroutine(Delay());
	}

	IEnumerator Delay()
	{
		yield return new WaitForSeconds(time);
		GetComponent<NetcodeTransform>().SetVelocity(new Vector3(0, -5, 0));
		Destroy(this);
	}
}